package ooday04;

import java.util.Timer;
import java.util.TimerTask;

//匿名内部类的练习---定时器（定时做任务）
public class TimerDemo {
    public static void main(String[] args) {
        Timer tim=new Timer();
        int interval=2000;
        tim.schedule(new TimerTask() {
            public void run() {
                System.out.println("该敲代码了...");
            }
        }, interval, interval);










        /*
        Timer timer = new Timer();//定时器对象
        int interval = 1000;//定时间隔（以毫秒为单位）
        //
        timer.schedule(new TimerTask() {
            public void run() {
                System.out.println("该学习了...");
            }
        }, 5000, 1000);//定时计划表

        /*
        Timer t = new Timer();
        timer.schedule(new TimerTask() {
            public void run() {
                System.out.println(
                        "哈哈"
                );
            }
        }, 2000, 2000);

         */

    }

}
